home *** CD-ROM | disk | FTP | other *** search
- class CodeBox
- {
- var bInvincible;
- var mcRef;
- static var aRIGHT_CODES = ["PUPUNUNU"];
- function CodeBox(__mcRef)
- {
- this.bInvincible = false;
- Main.Instance.doAddListener(this);
- }
- function doEnterFrame()
- {
- if(this.mcRef._currentframe == 2)
- {
- if(this.mcRef.mcCodeEnterBox._currentframe == this.mcRef.mcCodeEnterBox._totalframes)
- {
- if(this.bInvincible)
- {
- this.doGoToFrame(3);
- }
- else
- {
- this.doGoToFrame(1);
- }
- }
- }
- }
- function setBox(_mcRef)
- {
- this.mcRef = _mcRef;
- if(!this.bInvincible)
- {
- this.doGoToFrame(1);
- }
- else
- {
- this.doGoToFrame(3);
- }
- }
- function onExitBox()
- {
- this.mcRef.mcCodeEnterBox.play();
- }
- function onTurnOffClick()
- {
- this.bInvincible = false;
- this.doGoToFrame(1);
- }
- function doConfirmCode()
- {
- var _loc2_ = this.mcRef.mcCodeEnterBox.mcField.txtCode.text;
- this.bInvincible = Library.Utils.Tools.isItemInArray(CodeBox.aRIGHT_CODES,_loc2_.toUpperCase());
- if(this.bInvincible)
- {
- this.mcRef.mcCodeEnterBox.play();
- }
- else
- {
- this.mcRef.mcCodeEnterBox.mcInvalid._visible = true;
- }
- }
- function onEnterCodeClick()
- {
- this.doGoToFrame(2);
- }
- function get Invincible()
- {
- return this.bInvincible;
- }
- function doGoToFrame(_nFrame)
- {
- this.mcRef.gotoAndStop(_nFrame);
- switch(_nFrame)
- {
- case 1:
- this.mcRef.btnEnter.onRelease = Library.Utils.Delegate.create(this,this.onEnterCodeClick);
- break;
- case 2:
- this.mcRef.mcCodeEnterBox.btnConfirm.onRelease = Library.Utils.Delegate.create(this,this.doConfirmCode);
- this.mcRef.mcCodeEnterBox.btnExit.onRelease = Library.Utils.Delegate.create(this,this.onExitBox);
- this.mcRef.mcCodeEnterBox.mcInvalid._visible = false;
- break;
- case 3:
- this.mcRef.btnOff.onRelease = Library.Utils.Delegate.create(this,this.onTurnOffClick);
- }
- }
- }
-